/**
 * @author SHIXINGXING
 */

/* 新增菜单*/
function add_bak(){
    window.self.location="function.do?method=addFunction";
}
/* 新增菜单*/
function add(){
    var count = 0;
    var j = 0;
    for (var i = 0; i < document.getElementsByName("ids").length; i++) {
        if (document.getElementsByName("ids")[i].checked) {
            j = i;
            count++;
        }
    }
    if (count == 0) {
        alert("请选择需要新增的“子菜单”的菜单！");
        return;
    }
    if (count > 1) {
        alert("一次只能选择一个菜单！");
        return;
    }
    if (count == 1) {
        window.self.location = "function.do?method=addFunction&functionID=" +
        document.getElementsByName("ids")[j].value;
    }
}
/* 删除菜单*/
function del(){
    var flag = false;
    for (var i = 0; i < document.getElementsByName("ids").length; i++) {
        if (document.getElementsByName("ids")[i].checked) {
            flag = true;
        }
    }
    if (!flag) {
        alert("请选择需要删除的菜单！");
        return;
    }
    if (window.confirm("确认删除吗？")) {  
        with (document.getElementById("list")) {       
            method = "post";
            action = "function.do?method=delFunction";
            submit();
        }
    }
}
/* 编辑菜单*/
function edit(){
    var count = 0;
    var j = 0;
    for (var i = 0; i < document.getElementsByName("ids").length; i++) {
        if (document.getElementsByName("ids")[i].checked) {
            j = i;
            count++;
        }
    }
    if (count == 0) {
        alert("请选择需要修改的菜单！");
        return;
    }
    if (count > 1) {
        alert("一次只能修改一个菜单！");
        return;
    }
    if (count == 1) {
        window.self.location = "function.do?method=editFunction&functionID=" +
        document.getElementsByName("ids")[j].value;
    }
} 